﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 中介者模式.Mediator;

namespace 中介者模式
{

    /// <summary>
    /// 1 中介者模式（Mediator Pattern）
    /// 2 中介者模式的优缺点和应用
    /// 3 数据库设计的中介者模式
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            try
            {

                BaseCharacter teacher= new Teacher(){
                    Name="波多野结衣"
                };

                BaseCharacter mester = new Master()
                {
                    Name="大黄瓜"
                };

                BaseCharacter student = new Student()
                {
                    Name = "大黄瓜1"
                };


                BaseCharacter student2 = new Student()
                {
                    Name = "大黄瓜2"
                };


                BaseCharacter student3 = new Student()
                {
                    Name = "大黄瓜3"
                };

                BaseCharacter student4 = new Student()
                {
                    Name = "大黄瓜4"
                };

                #region  一个个发
                Console.WriteLine("********************************************");
                teacher.SendMessage("今晚过来上课", mester);
                Console.WriteLine("********************************************");
                mester.SendMessage("收到，波老师，我会准时通知大家的，哈哈", teacher);
                Console.WriteLine("********************************************");
                mester.SendMessage("今晚波老师的课，请大家不要错过，哈哈", student);
                Console.WriteLine("********************************************");
                #endregion

                #region  一个多对（直接发给中介）
                {
                    BaseMediator mediator = new BaseMediator();
                    mediator.AddCharacter(mester);
                    mediator.AddCharacter(student);
                    mediator.AddCharacter(student2);
                    mediator.AddCharacter(student3);
                    mediator.AddCharacter(student4);
                    mediator.SendMessage("今晚波老师的课，请大家不要错过，哈哈", mester);


                    Console.WriteLine("*********************************");
                    mediator.SendMessage("收到一定前来", student4);
                }
                #endregion


              

            }
            catch (Exception ex)
            {

                throw ex;
            }
            Console.Read();
        }
    }
}
